package com.middlegroup.pay.mapper;

import com.baomidou.mybatisplus.mapper.BaseMapper;
import com.middlegroup.pay.entity.RefundBills;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

/**
 * <p>
 * 退款订单表 Mapper 接口
 * </p>
 *
 * @author liguangcun123
 * @since 2019-08-09
 */
public interface RefundBillsMapper extends BaseMapper<RefundBills> {
    /**
     * 查询是否存在退款处理中的订单
     * @param merchantBillNo
     * @return
     */
    @Select("select 1 from t_refund_bills where merchant_bill_no=#{merchantBillNo} and status=0 limit 1")
    String getByMerchantBillNo(@Param("merchantBillNo") String merchantBillNo);
    /**
     * 查询是否存在退款的订单
     * @param merchantBillNo
     * @return
     */
    @Select("select * from t_refund_bills where merchant_bill_no=#{merchantBillNo} and status=0 limit 1")
    RefundBills getByMBillNo(@Param("merchantBillNo") String merchantBillNo);
    
    @Select("select * from t_refund_bills where refund_no=#{refundNo} and status=0 limit 1")
    RefundBills getByRefundNo(@Param("refundNo") String refundNo);

    /**根据第三方返回的退款码查询
     * @param outRequestNo
     * @return
     */
    @Select("select * from t_refund_bills where out_request_no=#{outRequestNo}")
    RefundBills getByOutRequestNo(@Param("outRequestNo") String outRequestNo);


    RefundBills getRefundBills(RefundBills refundBills);
}
